package com.shoplook2025.category.model;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.Data;

import java.util.List;

/**
 * @author yan
 * @date 2025/8/25
 */
@TableName("category")
@Data
public class Category {
    @TableId(type = IdType.AUTO)
    private Integer id;
    private Integer parentId;
    @TableField(condition = SqlCondition.LIKE,whereStrategy = FieldStrategy.NOT_EMPTY)
    private String name;
    private String icon;
    private Integer sort;
    private String description;

    //父分类
    //序列化忽略该字段，反序列化时会自动填充该字段
    @TableField(exist = false)
    @JsonBackReference
    private Category parent;

    //所有子类别
    //忽略该字段，在表中不存在
    @TableField(exist = false)
    @JsonManagedReference
    private List<Category> children;
}
